package com.cssw.fyzb.busi.api.live;

import com.cssw.fyzb.busi.service.live.AnchorService;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @description: 修改直播封面
 * @author: zzf
 * @time: 2020/12/25 19:56
 */
@Function(description = "修改封面", parameters = {
        @Parameter(name = "anchorId", type = Type.String, description = "主播标识", required = true),
        @Parameter(name = "thumb", type = Type.String, description = "封面", required = true)
})
@Component
public class UpdateThumb implements Action {
    private final static Logger logger = LoggerFactory.getLogger(UpdateThumb.class);

    @Autowired
    AnchorService anchorService;

    @Override
    public Response execute(Request request) {
        Long anchorId = request.getLong("anchorId");
        String thumb = request.getString("thumb");
        try {
            anchorService.updateThumb(anchorId, thumb);
            return Response.success();
        } catch (Exception e) {
            logger.debug("", e);
            return Response.fail("操作失败");
        }
    }
}
